<template>
  <div class="hello">
    <textarea rows="20" cols="150" v-model="code"></textarea>
    <button @click="handleClick">替换</button>
    <textarea rows="20" cols="150" v-model="code1"></textarea>
  </div>
</template>

<script>
import * as babel from "@babel/core";

export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  data() {
    return {
      code: `export default {		
    methods: {
		getAge() {
			console.log(111);
		},
        getName() {
            Http.callService({
				url: "fs/file/upload/token"
			})
			.success((result) => {
				let formData = new FormData();
			})
			.fail(function(data, msg) {
				MsgBox.alert(msg);
			});
        }
    }			              
}`,
    code1: '',
    };
  },
  methods: {
    handleClick() {
      console.warn(this.code);
      babel.transform(this.code, {

      }, function(err, result) {
          console.warn(err, result);
      });
    },
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
